package likouJava;

public class 盛最多水的容器 {
    public int maxArea(int[] height) {
      int maxWater = 0, left = 0, right = height.length - 1 ;
      while (left < right){
          int area = Math.min(height[left],height[right]) * (right - left);
          maxWater = Math.max(area,maxWater);

          if(height[left] > height[right]){
              right --;
          }else {
              left ++;
          }

      }
      return maxWater;
    }

    public static void main(String[] args) {
        盛最多水的容器 solution = new 盛最多水的容器();
        int[] height ={1,8,6,2,5,4,8,3,7};
        int result = solution.maxArea(height);
        System.out.println(result);
    }


}
